using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PatientMap : EntityTypeConfiguration<Patient>
    {
        public PatientMap()
        {
            // Primary Key
            this.HasKey(t => new { t.home_phone, t.All_phones, t.Pedo, t.IID });

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(101);

            this.Property(t => t.FName)
                .HasMaxLength(45);

            this.Property(t => t.Full_name)
                .HasMaxLength(60);

            this.Property(t => t.Arabic_Full_Name)
                .HasMaxLength(60);

            this.Property(t => t.First_Name)
                .HasMaxLength(50);

            this.Property(t => t.Arabic_First_Name)
                .HasMaxLength(50);

            this.Property(t => t.Last_Name)
                .HasMaxLength(50);

            this.Property(t => t.Arabic_Last_Name)
                .HasMaxLength(50);

            this.Property(t => t.home_phone)
                .IsRequired()
                .HasMaxLength(19);

            this.Property(t => t.All_phones)
                .IsRequired()
                .HasMaxLength(79);

            this.Property(t => t.REV_NAME)
                .HasMaxLength(101);

            this.Property(t => t.doctor_nb)
                .HasMaxLength(6);

            this.Property(t => t.ADDRESS)
                .HasMaxLength(200);

            this.Property(t => t.CITY)
                .HasMaxLength(30);

            this.Property(t => t.STATE)
                .HasMaxLength(3);

            this.Property(t => t.ZIP)
                .HasMaxLength(14);

            this.Property(t => t.WORK_PH1)
                .HasMaxLength(19);

            this.Property(t => t.WORK_PH2)
                .HasMaxLength(19);

            this.Property(t => t.MOBILE)
                .HasMaxLength(19);

            this.Property(t => t.FAX)
                .HasMaxLength(19);

            this.Property(t => t.CaseNb)
                .HasMaxLength(15);

            this.Property(t => t.SEX)
                .HasMaxLength(7);

            this.Property(t => t.ANAME)
                .HasMaxLength(110);

            this.Property(t => t.IID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Short_name)
                .HasMaxLength(40);

            this.Property(t => t.Arabic_Short_Name)
                .HasMaxLength(40);

            // Table & Column Mappings
            this.ToTable("Patient");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.FName).HasColumnName("FName");
            this.Property(t => t.Full_name).HasColumnName("Full_name");
            this.Property(t => t.Arabic_Full_Name).HasColumnName("Arabic_Full_Name");
            this.Property(t => t.First_Name).HasColumnName("First_Name");
            this.Property(t => t.Arabic_First_Name).HasColumnName("Arabic_First_Name");
            this.Property(t => t.Last_Name).HasColumnName("Last_Name");
            this.Property(t => t.Arabic_Last_Name).HasColumnName("Arabic_Last_Name");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.home_phone).HasColumnName("home_phone");
            this.Property(t => t.All_phones).HasColumnName("All_phones");
            this.Property(t => t.REV_NAME).HasColumnName("REV_NAME");
            this.Property(t => t.doctor_nb).HasColumnName("doctor_nb");
            this.Property(t => t.ADDRESS).HasColumnName("ADDRESS");
            this.Property(t => t.CITY).HasColumnName("CITY");
            this.Property(t => t.STATE).HasColumnName("STATE");
            this.Property(t => t.ZIP).HasColumnName("ZIP");
            this.Property(t => t.birthdate).HasColumnName("birthdate");
            this.Property(t => t.WORK_PH1).HasColumnName("WORK_PH1");
            this.Property(t => t.WORK_PH2).HasColumnName("WORK_PH2");
            this.Property(t => t.MOBILE).HasColumnName("MOBILE");
            this.Property(t => t.FAX).HasColumnName("FAX");
            this.Property(t => t.CaseNb).HasColumnName("CaseNb");
            this.Property(t => t.Pedo).HasColumnName("Pedo");
            this.Property(t => t.SEX).HasColumnName("SEX");
            this.Property(t => t.ANAME).HasColumnName("ANAME");
            this.Property(t => t.IID).HasColumnName("IID");
            this.Property(t => t.Short_name).HasColumnName("Short_name");
            this.Property(t => t.Arabic_Short_Name).HasColumnName("Arabic_Short_Name");
        }
    }
}
